package io.renren.modules.bike.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.bike.entity.PlaceEntity;
import io.renren.modules.bike.service.PlaceService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2022-03-14 10:48:53
 */
@RestController
@RequestMapping("bike/place")
public class PlaceController {
    @Autowired
    private PlaceService placeService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("bike:place:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = placeService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{pid}")
    @RequiresPermissions("bike:place:info")
    public R info(@PathVariable("pid") Integer pid){
		PlaceEntity place = placeService.getById(pid);

        return R.ok().put("place", place);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("bike:place:save")
    public R save(@RequestBody PlaceEntity place){
		placeService.save(place);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("bike:place:update")
    public R update(@RequestBody PlaceEntity place){
		placeService.updateById(place);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("bike:place:delete")
    public R delete(@RequestBody Integer[] pids){
		placeService.removeByIds(Arrays.asList(pids));

        return R.ok();
    }

}
